﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DTN.Core;
using Hanel.DTN.News;

public partial class Control_Home_panelXaHoi : System.Web.UI.UserControl
{
    ItblContentManager obj = tblContentManager.CreateInstance();
    ItblOS_Crawer_ChannelsManager objChannel = tblOS_Crawer_ChannelsManager.CreateInstance();
    protected void Page_Load(object sender, EventArgs e)
    {
        DisplayXaHoi();
        DisplayVanHoa();
        DisplayThethao();
    }
    protected void DisplayXaHoi()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 1", "Status=1 and ChannelID=97", "ID_Content desc");
        int id = int.Parse(dt.Rows[0]["ID"].ToString());
        DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=97 and id<>" + id, "ID_Content desc");

        DataList1.DataSource = dt;
        DataList1.DataBind();
        DataList2.DataSource = dt2;
        DataList2.DataBind();
    }

    protected void DisplayVanHoa()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 1", "Status=1 and ChannelID=48", "ID_Content desc");
        int id = int.Parse(dt.Rows[0]["ID"].ToString());
        DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=48 and id<>" + id, "ID_Content desc");

        DataList3.DataSource = dt;
        DataList3.DataBind();
        DataList4.DataSource = dt2;
        DataList4.DataBind();
    }

    protected void DisplayThethao()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 1", "Status=1 and ChannelID=98", "ID_Content desc");
        int id = int.Parse(dt.Rows[0]["ID"].ToString());
        DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=98 and id<>" + id, "ID_Content desc");

        DataList5.DataSource = dt;
        DataList5.DataBind();
        DataList6.DataSource = dt2;
        DataList6.DataBind();
    }
    public string BindMenuXaHoi()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 97", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">"+dr["Name"]+"</a>";               
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }
          
        }
        catch
        {
            return data;
        }
        return data;
    }
    public string BindMenuVanHoa()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 48", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">" + dr["Name"] + "</a>";
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }

        }
        catch
        {
            return data;
        }
        return data;
    }
    public string BindMenuTheThao()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 98", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">" + dr["Name"] + "</a>";
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }

        }
        catch
        {
            return data;
        }
        return data;
    }

}